(* For some reaason this is the only way to resolve 'hd'. *)
open List;;

(* Can't get to work with pattern matching ``n :: ns``; case triggers a typing
 * error. *)
let rec hi_people names =
    if List.length names = 1 then
        "and " ^ hd names
    else
        hd names ^ ", " ^  hi_people (tl names)
;;


let say_hi args =
    (* Could have also used 'function' and left out ``match _ with ...``. *)
    match args with
      [] -> "World"
    | name :: [] -> name
    (* Leaving an empty pattern match triggers a compile-time error about a
     * possibly bad match with a single string. *)
    | name :: names -> hi_people (name :: names)
;;



print_endline ("Hello, " ^ say_hi (tl (Array.to_list Sys.argv)) ^ "!")
